package com.project.nimsen.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Repository;
/**
 * web里的基础信息
 * */
@Repository("webUtil")
public class WebUtil {
	/**
	 * 得到网站的根目录
	 * */
	public static String webUrl(HttpServletRequest request){
		String domainname = request.getServerName();
		HttpSession session = request.getSession();
		if(session.getAttribute("ctx")==null){
			//得到配置的web站点根目录
			String ctx =request.getScheme() + "://" + domainname + ":" + request.getServerPort()+request.getContextPath();
			session.setAttribute("ctx", ctx);
		}
		return (String)session.getAttribute("ctx");
	}
}
